package com.maruti.otterapi.stats;

import com.maruti.otterapi.Otter4JavaException;
import com.maruti.otterapi.TopsyConfig;
import com.maruti.otterapi.TopsyConstants;
import com.maruti.otterapi.TopsyInvoker;

public class Stats {

	private TopsyConfig topsyConfig;

	public TopsyConfig getTopsyConfig() {
		return topsyConfig;
	}

	public void setTopsyConfig(TopsyConfig topsyConfig) {
		this.topsyConfig = topsyConfig;
	}

	public StatsResponse stats(String url) throws Otter4JavaException {
		return stats(url, null);
	}

	public StatsResponse stats(String url, String contains)
			throws Otter4JavaException {
		TopsyInvoker invoker = new TopsyInvoker();
		invoker.setTopsyConfig(topsyConfig);

		String params = url;
		params += "&contains=" + contains;

		StatsResponse data = (StatsResponse) invoker.fetchData(
				TopsyConstants.statsURL + params, "stats");

		return data;
	}
}
